<template>
  <div class="uploadList" align="center">
    <el-upload
      class="upload-demo"
      ref="upload"
      action="#"
      :auto-upload="false"
      :limit="1"
      :accept="options.accept || '.xlsx, .xls'"
      drag
      v-bind="options"
      v-on="options">
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
      <div class="el-upload__tip text-center" slot="tip">
        <slot>
          <template>
            <span>仅允许导入xls、xlsx格式文件。</span>
            <template>
              <el-link type="primary" :underline="false" @click="down && down.click()">下载模板</el-link>
            </template>
          </template>
        </slot>
      </div>
    </el-upload>
  </div>
</template>

<script>
export default {
  name: "UploadList",
  props: ['options', 'visible', 'down'],
  data() {
    return {};
  },
  watch: {
    'visible':{
      handler(newval, old) {
        if(!newval){
          this.$refs['upload'].clearFiles()
        }
      }
    }
  },
  methods: {
    onSubmitFile() {
      this.$refs['upload'].submit()
    }
  },
};
</script>

<style scoped lang="scss"></style>

